const connect = require('connect');
const morgan = require('morgan');
const fs = require('fs');
const path = require('path');

const log = fs.createWriteStream(path.join(__dirname, 'logger-access.log'), {
  flags: 'a'
});
connect()
  .use(
    morgan({
      format: ':method :url',
      stream: log,
      immediate: true,
      buffer: true
    })
  )
  .use(hello)
  .listen(3000);

function hello(req, res) {
  res.end('hello\n');
}
